<?php
require_once ("../dbconnect.php");

$name = $_GET["name"];

$db = dbconnect();

$sql = "SELECT i.id, i.text, c.description FROM characters AS c, images AS i WHERE " .
		"c.name='$name' AND c.image=i.id";
		
$result = $db->query($sql);

if ( $result ) {
    while($row = $result->fetchRow()){
    	$image = $row[0];
    	$text = $row[1];
    	$description = nl2br(htmlspecialchars($row[2]));
    	echo "<p><img src=\"server/view.php?image=$image\" alt=\"$text\"></p>\n\n";
    	echo $description;
    }
}

$db->disconnect();
?>